package com.example.demo.server3.template;

import io.netty.buffer.ByteBuf;
import io.netty.util.CharsetUtil;

public class CMPP_CONNECT implements ProtocolTemplate {
    private MessageHeader messageHeader;
    private String Source_Addr;
    private String AuthenticatorSource;
    private byte Version;
    private int Timestamp;

    public void structure(ByteBuf buf){
        Source_Addr = buf.toString(12,6,CharsetUtil.US_ASCII);//这里需要注意字符集协议是哪种
        AuthenticatorSource = buf.toString(18,16,CharsetUtil.US_ASCII);
        Version = buf.getByte(34);//这里cmpp协议显示只是一个字节,有疑问
        Timestamp = buf.getInt(35);
    }

    @Override
    public ByteBuf destruct() {
        return null;
    }

    public MessageHeader getMessageHeader() {
        return messageHeader;
    }

    public void setMessageHeader(MessageHeader messageHeader) {
        this.messageHeader = messageHeader;
    }

    public String getSource_Addr() {
        return Source_Addr;
    }

    public void setSource_Addr(String source_Addr) {
        Source_Addr = source_Addr;
    }

    public String getAuthenticatorSource() {
        return AuthenticatorSource;
    }

    public void setAuthenticatorSource(String authenticatorSource) {
        AuthenticatorSource = authenticatorSource;
    }

    public byte getVersion() {
        return Version;
    }

    public void setVersion(byte version) {
        Version = version;
    }

    public int getTimestamp() {
        return Timestamp;
    }

    public void setTimestamp(int timestamp) {
        Timestamp = timestamp;
    }
}
